<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%
String quizName = (String)request.getParameter("QuizName");
int quizId = Integer.parseInt( request.getParameter("QuizId") );
Question q = (Question)request.getAttribute("question");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page import="java.util.List"%>
<%@page import="soen343.domain.Question"%>
<%@page import="soen343.application.presentation.QuestionSnippetJSPFactory"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link rel="stylesheet" href="style/global.css" type="text/css" />
<script language="JavaScript" type="text/javascript" src="javascript/global.js"></script>
<script language="JavaScript" type="text/javascript" src="javascript/editQuestion.js"></script>
<title>Edit Question</title>
</head>
<body>
<noscript><div id="jsDisabled">JavaScript must be enabled to use Quiz Manager</div></noscript>
<%	List<String> errors = (List<String>) request.getAttribute("errors");
	if( errors != null && !errors.isEmpty() ) {
%>
	<div class="errors">
		<p>Errors:</p>
		<ul>
<%	for( String error : errors ){ %>
			<li><%=error %></li>
<%	} %>
		</ul>
	</div>
<%	} %>
<form method="post" action="FrontController">
	<div class="question">
		<div class="questionName"><label for="name">Question Name:</label>
			<input type="text" id="name" name="name" value="<%=q.getName() %>" /></div>
		<div class="questionText"><label for="text">Question Text:</label>
			<input type="text" id="text" name="text" value="<%=q.getText() %>" /></div>
		<div class="questionInput">
			<jsp:include page="<%=QuestionSnippetJSPFactory.getEditJSPSnippet(q) %>" />
		</div>
	</div>
	<input type="hidden" name="QuizId" value="<%=quizId %>" />
	<input type="hidden" name="QuestionId" value="<%=q.getId() %>" /><input type="submit" value="Save" /></form>
	<form method="post" action="FrontController">
	<input type="hidden" name="command" value="EditQuiz" />
	<input type="hidden" name="QuizId" value="<%=quizId %>" /><input type="submit" value="Cancel" /></form>
</body>
</html>